import { createRouter, createWebHistory } from 'vue-router'
import Chat from "@/view/Chat.vue";
import LoginMenu from "@/components/Login/LoginMenu.vue";
import * as path from "node:path";
import BoughtOrders from "@/view/BoughtOrders.vue";
import Cart from "@/view/Cart.vue";
import SoldOrders from "@/view/SoldOrders.vue";
import Index from "@/view/Index.vue";
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    // 搭配 import 使用
    // {
    //   path: '/',
    //   name: 'home',
    //   component: HomeView, //提前导入组件
    // },

    // {
    //   path: '/personal',
    //   name: 'PersonalCenter',
    //   component: CenterView, // 使用 views/CenterView.vue 作为主视图
    // },
    // {
    //   path: '/personal/collection',
    //   name: 'MyCollection',
    //   component: MyCollection, // 收藏详情页
    // },
    // {
    //   path: '/personal/history',
    //   name: 'MyHistory',
    //   component: MyHistory, // 历史详情页
    // },
    // {
    //   path: '/personal/follow',
    //   name: 'MyFollow',
    //   component: MyFollow, // 关注详情页
    // },
    // {
    //   path: '/personal/coupon',
    //   name: 'MyCoupon',
    //   component: MyCoupon, // 卡券详情页
    // },
    // {
    //   path: '/personal/myposted',
    //   name: 'MyPosted',
    //   component: MyPosted
    // },
    // {
    //   path: '/personal/mysold',
    //   name: 'MySold',
    //   component: MySold
    // },
    // {
    //   path: '/personal/mybought',
    //   name: 'MyBought',
    //   component: MyBought
    // },
    {
      path: '/home', // 首页路径
      name: 'home',
      component:Index  // 首页渲染
    },
    {
      path: '/',
      name: 'login',
      component: LoginMenu
    },
    {
      path: '/signMenu',
      name: 'signMenu',
      component: () => import('@/components/Sign/SignMenu.vue'),
    },
    {
      path: '/chat',
      name: 'chat',
      component: Chat,
    },
    {
      path: '/chatbox/:currentUserId/:otherUserId', //路径传参结合 query eg:{path: '/chatbox', query: {name: 'xxx', age: 10}}
      name: 'chatbox', //名字传参结合 params eg:{name: 'chatbox', params: {name: 'xxx', age: 10}}
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('@/components/ChatBox/ChatBox.vue'),
    },
    {
      path: '/boughtorders', //买入历史
      name: 'boughtorders',
      component: BoughtOrders
    },
    {
      path: '/soldorders',//卖出历史
      name: 'soldorders',
      component: SoldOrders,
    },
    {
      path: '/cart',//购物车
      name: 'cart',
      component: Cart,
    },
  ],
})

export default router
